import { createApp } from 'vue';
import App from './App.vue';
import router from './router';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import axios from 'axios';
import * as ElementPlusIconsVue from '@element-plus/icons-vue';

// 创建应用程序实例
const app = createApp(App);

// 挂载全局属性
app.config.globalProperties.$axios = axios;

// 使用 Element Plus
app.use(ElementPlus);

// 全局注册图标组件
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
// 抑制 ResizeObserver 无害错误
const resizeObserverErrCheck = err => {
  return err.message.includes('ResizeObserver') && 
         !err.message.includes('Script error');
};

window.addEventListener('error', e => {
  if (resizeObserverErrCheck(e.error)) {
    e.stopImmediatePropagation();
    e.stopPropagation();
  }
});

window.onerror = (msg, src, line, col, err) => {
  if (resizeObserverErrCheck(err)) return true;
};
// 使用路由
app.use(router);

// 挂载应用
app.mount('#app');
